from django.db import models


# Create your models here.


class User(models.Model):
    """用户表"""
    username = models.CharField(max_length=10, verbose_name="用户名")
    nickname = models.CharField(max_length=10, verbose_name="昵称")
    realname = models.CharField(max_length=10, verbose_name="真实姓名")
    tel = models.CharField(max_length=20, verbose_name="手机号")
    email = models.EmailField(verbose_name="邮箱")

    password = models.CharField(max_length=50, verbose_name="密码")
    birth = models.DateField(null=True, verbose_name="生日")
    sex = models.CharField(max_length=10, verbose_name="性别")
    status = models.IntegerField(default=1, verbose_name="状态")
    usertpye = models.CharField(max_length=20, default="普通用户")
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="注册时间")
    is_del = models.IntegerField(default=0, verbose_name="是否注销")
    points = models.IntegerField(default=20, verbose_name="积分")
    icon = models.FileField(null=True, verbose_name="头像", upload_to="icon")


class Captcha(models.Model):
    email = models.ForeignKey(User, on_delete=models.CASCADE,verbose_name="emails")
    captcha = models.CharField(max_length=4, verbose_name="验证码")
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")


class Follow(models.Model):
    """关注表"""
    userId = models.ForeignKey(User, on_delete=models.CASCADE, related_name="users")
    followId = models.ForeignKey(User, on_delete=models.CASCADE, related_name="follows")
